//
//  TPLabelTextField.m
//  CloudAtCostPanel
//
//  Created by leonardo on 2017/1/26.
//  Copyright © 2017年 tanpengsccd. All rights reserved.
//

#import "TPLabelTextField.h"

#import <Masonry.h>

@implementation TPLabelTextField

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/



//- (instancetype)init
//{
//    self = [super init];
//    if (self) {
////        [self addSubviews];
////        [self addConstraints];
////        [self addActions];
//        
//    }
//    return self;
//}

- (instancetype)initWithIsVertical:(BOOL)isVertical label:(UILabel *)label textField:(UITextField *)textField{
    
    self = [super init];
    if (self) {
        
        self.label = label;
        self.textField = textField;
        
        [self addSubview:self.label];
        [self addSubview:self.textField];
        if (!isVertical) {//横向排列
            
            [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo( self.label.superview);
                make.left.mas_equalTo( self.label.superview);
                make.width.mas_equalTo(60);
            }];
            
            [self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo( self.textField.superview);
                make.left.mas_equalTo( self.label.mas_right);
                make.right.mas_equalTo( self.textField.superview.mas_right);
            }];
        }else{//纵向排列
            
#warning TODO
        }
        
        self.userInteractionEnabled = YES;
        
    }
    return self;

}

/**
 *  最常用横向LabelTextField
 *
 *  @param labelStr                <#labelStr description#>
 *  @param textFieldPlaceHolderStr <#textFieldPlaceHolderStr description#>
 *
 *  @return <#return value description#>
 */
- (instancetype)initWithHorizonalLabelStr:(NSString *)labelStr textFieldPlaceHolderStr:(NSString *)textFieldPlaceHolderStr {
    return  [self initWithIsVertical:NO labelStr:labelStr labelColor:COLOUR_CONTENT labelFont:FONTSIZE_CONTENT textFieldPlaceholderStr:textFieldPlaceHolderStr textFieldStr:@"" textFieldColor:COLOUR_CONTENT textFieldFont:FONTSIZE_CONTENT];
    
    
}


/**
 *  完整
 *
 *  @param isVertical              <#isVertical description#>
 *  @param labelStr                <#labelStr description#>
 *  @param labelColor              <#labelColor description#>
 *  @param labelFont               <#labelFont description#>
 *  @param textFieldPlaceholderStr <#textFieldPlaceholderStr description#>
 *  @param textFieldStr            <#textFieldStr description#>
 *  @param textFieldColor          <#textFieldColor description#>
 *  @param textFieldFont           <#textFieldFont description#>
 *
 *  @return <#return value description#>
 */
- (instancetype)initWithIsVertical:(BOOL)isVertical labelStr:(NSString *)labelStr labelColor:(UIColor *)labelColor labelFont:(UIFont*)labelFont textFieldPlaceholderStr:(NSString *)textFieldPlaceholderStr textFieldStr:(NSString *)textFieldStr textFieldColor:(UIColor *)textFieldColor textFieldFont:(UIFont *)textFieldFont
{
    
    UILabel * label = [[UILabel alloc]init];
    label.textColor = labelColor;
    label.font = labelFont;
    label.text = labelStr;
//    label.textAlignment = NSTextAlignmentRight;
    
    UITextField * textField = [[UITextField alloc]init];
    textField.textColor = textFieldColor;
    textField.font =textFieldFont;
    textField.placeholder = textFieldPlaceholderStr;
    textField.text = textFieldStr;
//    textField.backgroundColor = COLOUR_RED;
    
    self = [self initWithIsVertical:isVertical label:label textField:textField];
    return self;
}

- (void)addSubviews{
    
}

- (void)addConstraints{
    
}

- (void)addActions{
    
}
@end
